<!DOCTYPE HTML>
<html lang="en">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Eggjs,Webpack,easywebpack,Egg React SSR,Egg Vue SSR, web ide, Flutter, React Native,Egg/前端工程/多端技术-Flutter  Android  混合工程实践, 前端工程化, node, egg, webpack, easywebpack, ves, res, ssr, react server side render, vue server side render">
    <meta name="description" content="Egg/前端工程/多端技术,在 Flutter 混合工程体系 一文中，阐述了Flutter 三种开发模式，在实际业务中搭建持续集成时，我们更希望发本地开发使用混合模式，持续集成使用解耦模式， 主要是解决以下两个问题： 混合模式：开发调试方便，包括热更新， Native 与 Flutter 开发源码断点调试 解耦模式：不侵...">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Egg/前端工程/多端技术-Flutter  Android  混合工程实践 | easy-team</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper head-container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">easy-team</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>Home</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/res" class="waves-effect waves-light">
      
      <i class="fas fa-forward" style="zoom: 0.6;"></i>
      
      <span>Res</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/ves" class="waves-effect waves-light">
      
      <i class="fas fa-forward" style="zoom: 0.6;"></i>
      
      <span>Ves</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fas fa-list" style="zoom: 0.6;"></i>
      
      <span>Egg</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="/egg-react">
          
          <i class="fas fa-forward" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>Egg+React</span>
        </a>
      </li>
      
      <li>
        <a href="/egg-vue">
          
          <i class="fas fa-forward" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>Egg+Vue</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/easywebpack" class="waves-effect waves-light">
      
      <i class="fas fa-building" style="zoom: 0.6;"></i>
      
      <span>Webpack</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog" class="waves-effect waves-light">
      
      <i class="fas fa-hacker-news" style="zoom: 0.6;"></i>
      
      <span>Blog</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>About</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>Contact</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="Search" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">easy-team</div>
        <div class="logo-desc">
            
            Node, 前端工程化, 多端技术
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			Home
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/res" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-forward"></i>
			
			Res
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/ves" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-forward"></i>
			
			Ves
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-list"></i>
			
			Egg
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="/egg-react " style="margin-left:75px";>
				  
				   <i class="fa fas fa-forward" style="position: absolute;left:50px" ></i>
			      
		          <span>Egg+React</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/egg-vue " style="margin-left:75px";>
				  
				   <i class="fa fas fa-forward" style="position: absolute;left:50px" ></i>
			      
		          <span>Egg+Vue</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/easywebpack" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-building"></i>
			
			Webpack
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/blog" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-hacker-news"></i>
			
			Blog
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			About
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			Contact
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/easy-team" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/easy-team" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    <div class="bg-cover pd-header" style="height: 9vh">
    <div class="container"></div>
</div>


    <script>
        // 每天切换 banner 图.  Switch banner image every day.
        $('.bg-cover').css('background-image', 'url(/medias/banner/' + new Date().getDay() + '.jpg)');
    </script>
    

<div class="doc-content">
    
     <div class="doc-left-nav" style="width:400px">
        <div class="side-nav docsidenav" style="width:400px">
    <div class="doc-left-nav-title">blog</div>
    <ul class="menu-list mobile-menu-list">
        
            
                <li class="m-nav-item">
                    <a href="/blog/cdal6o" class="waves-effect waves-light" id="m-nav-item-blog-cdal6o">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Egg + Web 自定义前端渲染
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/ruv09m" class="waves-effect waves-light" id="m-nav-item-blog-ruv09m">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Egg SSR Webpack 内存编译热更新实现
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/sg8avg" class="waves-effect waves-light" id="m-nav-item-blog-sg8avg">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Webpack Babel SSR 构建优化
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/zfri65" class="waves-effect waves-light" id="m-nav-item-blog-zfri65">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Webpack 构建大小分析与优化
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/xriz8a" class="waves-effect waves-light" id="m-nav-item-blog-xriz8a">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Egg + Vue/Nunjucks 服务端渲染性能测试
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/qwr449" class="waves-effect waves-light" id="m-nav-item-blog-qwr449">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Webpack 热更新实现原理分析
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/dxrrhq" class="waves-effect waves-light" id="m-nav-item-blog-dxrrhq">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Webpack 4 编译内存泄漏
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/kiygy5" class="waves-effect waves-light" id="m-nav-item-blog-kiygy5">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Vue SSR 组件加载
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/ekvirc" class="waves-effect waves-light" id="m-nav-item-blog-ekvirc">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        Webpack 构建流程解密
                    </a>
                </li>
            
        
            
                <li class="m-nav-item">
                    <a href="/blog/az519d" class="waves-effect waves-light" id="m-nav-item-blog-az519d">
                        
                        <i class="fas fa-fw fa-link"></i>
                        
                        页面资源加载
                    </a>
                </li>
            
        
            
                <li class="m-nav-item m-nav-show">
                    <a href="javascript:;">
                        <i class="fas fa-fw fa-link"></i>
                        Flutter 技术专题
                        <span class="m-icon"><i class="fas fa-chevron-right"></i></span>
                    </a>
                    <ul  style="display:block; background:  ;" >
                        
                            <li>   
                                <a id="m-nav-item-blog-lsrssy" href="/blog/lsrssy " 
                                    style="padding-left:75px";>
                                
                                <span>Flutter  Android  混合工程实践</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-zs3hog" href="/blog/zs3hog " 
                                    style="padding-left:75px";>
                                
                                <span>Flutter iOS 混合工程实践</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-nrswgq" href="/blog/nrswgq " 
                                    style="padding-left:75px";>
                                
                                <span>Android 与 Flutter 入门开发实践指引</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-wydpi1" href="/blog/wydpi1 " 
                                    style="padding-left:75px";>
                                
                                <span>Flutter 动态更新</span>
                                </a>
                            </li>
                         
                    </ul>
                </li>
            
        
            
                <li class="m-nav-item m-nav-show">
                    <a href="javascript:;">
                        <i class="fas fa-fw fa-link"></i>
                        React Native 技术专题
                        <span class="m-icon"><i class="fas fa-chevron-right"></i></span>
                    </a>
                    <ul  style="display:block; background:  ;" >
                        
                            <li>   
                                <a id="m-nav-item-blog-xcw19a" href="/blog/xcw19a " 
                                    style="padding-left:75px";>
                                
                                <span>React Native, Hybrid App, H5 简单对比分析</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-vzgcgb" href="/blog/vzgcgb " 
                                    style="padding-left:75px";>
                                
                                <span>React Native Android APK包大小分析</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-wk5ney" href="/blog/wk5ney " 
                                    style="padding-left:75px";>
                                
                                <span>React Native 自定义插件</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-kghphs" href="/blog/kghphs " 
                                    style="padding-left:75px";>
                                
                                <span>React Native代码执行跟踪和调试</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-qwywww" href="/blog/qwywww " 
                                    style="padding-left:75px";>
                                
                                <span>React Native 热更新实现</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-rh45zo" href="/blog/rh45zo " 
                                    style="padding-left:75px";>
                                
                                <span>React Native Android源码解读和交互原理分析</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-uhmdkg" href="/blog/uhmdkg " 
                                    style="padding-left:75px";>
                                
                                <span>Hybrid系列-phonegap android框架详解</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-sxys82" href="/blog/sxys82 " 
                                    style="padding-left:75px";>
                                
                                <span>Hybrid系列-Cordova android框架详解</span>
                                </a>
                            </li>
                         
                    </ul>
                </li>
            
        
            
                <li class="m-nav-item m-nav-show">
                    <a href="javascript:;">
                        <i class="fas fa-fw fa-link"></i>
                        开发工具使用
                        <span class="m-icon"><i class="fas fa-chevron-right"></i></span>
                    </a>
                    <ul  style="display:block; background:  ;" >
                        
                            <li>   
                                <a id="m-nav-item-blog-syh43v" href="/blog/syh43v " 
                                    style="padding-left:75px";>
                                
                                <span>npm 常用命令</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-vfhw62" href="/blog/vfhw62 " 
                                    style="padding-left:75px";>
                                
                                <span>Git 使用技巧</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-gayu0o" href="/blog/gayu0o " 
                                    style="padding-left:75px";>
                                
                                <span>Docker 随记</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-egret" href="/blog/egret " 
                                    style="padding-left:75px";>
                                
                                <span>Egret  游戏开发</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-og9ogk" href="/blog/og9ogk " 
                                    style="padding-left:75px";>
                                
                                <span>vscode 插件开发</span>
                                </a>
                            </li>
                        
                            <li>   
                                <a id="m-nav-item-blog-qz7n03" href="/blog/qz7n03 " 
                                    style="padding-left:75px";>
                                
                                <span>Mac PHP 环境</span>
                                </a>
                            </li>
                         
                    </ul>
                </li>
            
        
        <li><div class="divider"></div></li>
        
        <li>
            <a href="https://yuque.com/hubcarl" class="waves-effect waves-light" target="_blank">
                <i class="fas fa-fw fa-link"></i>语雀文档
            </a>
        </li>
        <li>
            <a href="https://github.com/hubcarl" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Github
            </a>
        </li>
    </ul>
</div>

     </div>
    
    <div class="doc-right-nav">
        <div class="card" class="doc-right-card">
            <div class="card-content article-info">
                <h1 style="margin-top: 12px; text-align: center;">Flutter  Android  混合工程实践</h1>
                
                <div class="post-info">
                    <div class="post-date info-break-policy">
                        <i class="far fa-calendar-minus fa-fw"></i>Date:&nbsp;&nbsp;
                        2019-10-20
                    </div>
    
                    
                        
                        <div class="info-break-policy">
                            <i class="far fa-file-word fa-fw"></i>Word Count:&nbsp;&nbsp;
                            1.9k
                        </div>
                        
    
                        
                        <div class="info-break-policy">
                            <i class="far fa-clock fa-fw"></i>Read Times:&nbsp;&nbsp;
                            9 Min
                        </div>
                        
                    
                    
                    
                        <div id="busuanzi_container_page_pv" class="info-break-policy">
                            <i class="far fa-eye fa-fw"></i>Read Count:&nbsp;&nbsp;
                            <span id="busuanzi_value_page_pv"></span>
                        </div>
                    
                </div>
            </div>
            <hr class="clearfix" style="margin: 0px 0px;">
            <div class="card-content article-card-content" style="padding-top: 0px;">
                <div id="articleContent">
                    <p>在 <a href="https://www.yuque.com/hubcarl/flutter/aylokm" target="_blank" rel="noopener">Flutter 混合工程体系 </a>一文中，阐述了Flutter 三种开发模式，在实际业务中搭建持续集成时，我们更希望发本地开发使用<strong>混合模式</strong>，持续集成使用<strong>解耦模式，</strong> 主要是解决以下两个问题：</p>
<ol>
<li><strong>混合模式</strong>：开发调试方便，包括热更新， Native 与 Flutter 开发源码断点调试</li>
<li><strong>解耦模式：</strong>不侵入 Android /iOS Native工程，不对 Flutter 环境产生依赖，可以单独独立构建打包</li>
</ol>
<p>我们这里重点阐述 <strong>解耦模式，</strong>要对 Android 与 Flutter 进行解藕，就需要分析<strong>混合模式</strong>最终生成的 APK 内容长啥样和 Flutter 构建脚本。</p>
<h2 id="Android-Flutter-APK-文件结构分析"><a href="#Android-Flutter-APK-文件结构分析" class="headerlink" title="Android Flutter APK 文件结构分析"></a>Android Flutter APK 文件结构分析</h2><p>我们通过 Android Studio  菜单 Build -&gt; Analyze APK  选择构建好的 Release APK 包，可以看到如下内容：</p>
<p><img src="https://cdn.nlark.com/yuque/0/2019/png/116733/1561086660607-bbc006fa-ebab-4bfe-bed4-ff08655509cf.png#align=left&display=inline&height=509&name=image.png&originHeight=509&originWidth=775&size=235136&status=done&width=775" alt="image.png"></p>
<p>通过上面 APK 结构，我们会发现Flutter 项目比普通的Android 项目多了如下几个文件：</p>
<blockquote>
<p>以下文件说明参考 <a href="https://blog.csdn.net/weixin_34001430/article/details/87942062" target="_blank" rel="noopener">https://blog.csdn.net/weixin_34001430/article/details/87942062</a></p>
</blockquote>
<ul>
<li>lib/armeabi-v7a/libflutter.so      - Flutter 引擎 </li>
<li>isolate_snapshot_instr               - 应用程序指令段</li>
<li>isolate_snapshot_data               - 应用程序数据段</li>
<li>vm_snapshot_instr                     - DartVM 指令段</li>
<li>vm_snapshot_data                     - DartVM 数据段</li>
<li>flutter_assets                             - 应用程序静态资源文件与配置</li>
</ul>
<h2 id="Flutter-项目-Gradle-构建脚本分析"><a href="#Flutter-项目-Gradle-构建脚本分析" class="headerlink" title="Flutter 项目 Gradle 构建脚本分析"></a>Flutter 项目 Gradle 构建脚本分析</h2><p>在 Flutter Android 工程里面，我们在 build.gradle 文件里面会看到 Flutter gradle 构建脚本：</p>
<pre class=" language-bash"><code class="language-bash">apply from: <span class="token string">"<span class="token variable">$flutterRoot</span>/packages/flutter_tools/gradle/flutter.gradle"</span></code></pre>
<p>进入 flutter.gradle 里面，我们会看到相关 flutter 的打包构建流程，主要包括三个部分：</p>
<ul>
<li><strong>apply 方法：</strong>flutter 引擎平台架构（arm, x86) 库处理 </li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2019/png/116733/1561088212471-4f80fc9d-3fb5-484f-8edb-8cceb5edff87.png#align=left&display=inline&height=511&name=image.png&originHeight=511&originWidth=903&size=444976&status=done&width=903" alt="image.png"></p>
<ul>
<li><strong>buildBundle 方法：</strong>flutter aot 和 bundle 编译处理，也就是上面所说的 snapshot 相关flutter 构建产物文件 </li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2019/png/116733/1561087824112-2399fa32-b62e-4e51-b9f5-f62de275a0ff.png#align=left&display=inline&height=652&name=image.png&originHeight=652&originWidth=890&size=411098&status=done&width=890" alt="image.png"></p>
<p>运行以后会发现其实执行的如下两条命令：</p>
<pre class=" language-bash"><code class="language-bash">// Debug
flutter build bundle  --debug

// release
flutter build aot  --release</code></pre>
<ul>
<li>*<em>getAssets: *</em>构建产物处理,  把 flutter snapshot 构建产物复制到 assets 目录，刚好与上面 APK 文件结构分析对应起来了。</li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2019/png/116733/1561087938933-515f994b-474b-4d52-8283-9845905861e9.png#align=left&display=inline&height=284&name=image.png&originHeight=284&originWidth=526&size=107624&status=done&width=526" alt="image.png"></p>
<h2 id="Android-Flutter-解耦处理"><a href="#Android-Flutter-解耦处理" class="headerlink" title="Android Flutter 解耦处理"></a>Android Flutter 解耦处理</h2><p>通过上面的 APK 文件和 Gradle 构建脚本分析，我们很清楚的知道了整个 Flutter 构建打包以及与Native 合并的过程， 接下来我们来进行 Android Native 工程 和 Flutter Module 工程解耦处理。</p>
<h4 id="Android-Native-项目依赖和构建配置处理"><a href="#Android-Native-项目依赖和构建配置处理" class="headerlink" title="Android Native 项目依赖和构建配置处理"></a>Android Native 项目依赖和构建配置处理</h4><ul>
<li>移除 Android Native 项目 ${root}/setting.gradle 对 flutter 构建的脚本的依赖</li>
</ul>
<pre class=" language-bash"><code class="language-bash">// 需要移除
evaluate<span class="token punctuation">(</span>new File<span class="token punctuation">(</span>
  settingsDir.parentFile,
  <span class="token string">'happyflutter/.android/include_flutter.groovy'</span>
<span class="token punctuation">))</span></code></pre>
<ul>
<li>移除 Android Native 项目 ${root}/app/build.gradle 对 flutter 引擎库的依赖 </li>
</ul>
<pre class=" language-bash"><code class="language-bash">dependencies <span class="token punctuation">{</span>
  implementation project<span class="token punctuation">(</span><span class="token string">':flutter'</span><span class="token punctuation">)</span> // 需要删除
<span class="token punctuation">}</span></code></pre>
<ul>
<li>Android Native 项目  ${root}/app/build.gradle 添加对 libs 文件夹的 .jar .aar 库</li>
</ul>
<pre class=" language-bash"><code class="language-bash">
dependencies <span class="token punctuation">{</span>
    // implementation project<span class="token punctuation">(</span><span class="token string">':flutter'</span><span class="token punctuation">)</span>
    implementation fileTree<span class="token punctuation">(</span>dir: <span class="token string">'libs'</span>, include: <span class="token punctuation">[</span><span class="token string">'*.jar'</span>, <span class="token string">'*.aar'</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre>
<h4 id="Flutter-Mobule-打包为独立的-aar-文件-gradle-脚本编写"><a href="#Flutter-Mobule-打包为独立的-aar-文件-gradle-脚本编写" class="headerlink" title="Flutter Mobule 打包为独立的 .aar 文件 gradle 脚本编写"></a>Flutter Mobule 打包为独立的 .aar 文件 gradle 脚本编写</h4><ul>
<li>修改 Flutter Module 项目构建类型 <strong>com.android.application</strong> 为  <strong>com.android.library</strong> </li>
<li>简化 *<em>$flutterRoot/packages/flutter_tools/gradle/flutter.gradle  *</em>构建逻辑</li>
<li>${root}/android/app/build.gradle 完整内容如下<pre class=" language-bash"><code class="language-bash"><span class="token function">import</span> java.nio.file.Path
<span class="token function">import</span> java.nio.file.Paths
</code></pre>
</li>
</ul>
<p>apply plugin: ‘com.android.library’</p>
<p>android {<br>    compileSdkVersion 28</p>
<pre><code>compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName &quot;1.0&quot;
    testInstrumentationRunner &quot;android.support.test.runner.AndroidJUnitRunner&quot;</code></pre><p>//        ndk {<br>//            abiFilters ‘x86’, ‘x86_64’, ‘armeabi-v7a’, ‘armeabi-v8a’, ‘armeabi’<br>//        }<br>    }</p>
<pre><code>buildTypes {
    profile {
        initWith debug
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;), &#39;proguard-rules.pro&#39;
    }
}
sourceSets {
    main {
        jniLibs.srcDirs &quot;jniLibs&quot;
    }
}</code></pre><p>}</p>
<p>// ${project.projectDir.getAbsolutePath()}<br>Properties properties = new Properties()<br>properties.load(project.rootProject.file(‘local.properties’).newDataInputStream())<br>String targetArch = ‘arm’<br>if (project.hasProperty(‘target-platform’) &amp;&amp; project.property(‘target-platform’) == ‘android-arm64’) {<br>    targetArch = ‘arm64’<br>}<br>// def isDebug = gradle.startParameter.taskNames.contains(“assembleDebug”)<br>// def platform = isDebug ? “android-x86” : “android-${targetArch}-release”<br>def flutterRoot = properties.getProperty(‘flutter.sdk’)<br>def flutterJarPath = “${flutterRoot}/bin/cache/artifacts/engine/android-${targetArch}-release/flutter.jar”</p>
<p>Path baseEnginePath = Paths.get(flutterRoot, “bin”, “cache”, “artifacts”, “engine”)<br>File debugFlutterJar = baseEnginePath.resolve(“android-${targetArch}”).resolve(“flutter.jar”).toFile()<br>File releaseFlutterJar = baseEnginePath.resolve(“android-${targetArch}-release”).resolve(“flutter.jar”).toFile()<br>File flutterX86Jar = baseEnginePath.resolve(“android-x86”).resolve(“flutter.jar”).toFile()<br>File flutterX64Jar = baseEnginePath.resolve(“android-x64”).resolve(“flutter.jar”).toFile()</p>
<p>//println flutterX86Jar.length()<br>//println flutterX86Jar.parentFile</p>
<p>Task flutterX86JarTask = project.tasks.create(“FlutterX86Jar”, Jar) {<br>    from(“${flutterRoot}/bin/cache/artifacts/engine/android-x86/libflutter.so”) {<br>        into “lib/x86”<br>    }<br>    from(“${flutterRoot}/bin/cache/artifacts/engine/android-x64/libflutter.so”) {<br>        into “lib/x86_64”<br>    }<br>}</p>
<p>project.android.buildTypes.each {<br>    addFlutterJarImplementationDependency(project, flutterX86JarTask, debugFlutterJar, releaseFlutterJar, flutterX86Jar, flutterX64Jar)<br>}<br>project.android.buildTypes.whenObjectAdded {<br>    addFlutterJarImplementationDependency(project, flutterX86JarTask, debugFlutterJar, releaseFlutterJar, flutterX86Jar, flutterX64Jar)<br>}</p>
<p>private void addFlutterJarImplementationDependency(Project project, Task flutterX86JarTask, File debugFlutterJar, File releaseFlutterJar, File flutterX86Jar,  File flutterX64Jar) {<br>    def isDebug = gradle.startParameter.taskNames.contains(“assembleDebug”)<br>    project.dependencies {<br>        String configuration<br>        if (project.getConfigurations().findByName(“implementation”)) {<br>            configuration = “implementation”<br>        } else {<br>            configuration = “compile”<br>        }<br>        add(configuration, project.files {<br>            if (isDebug) {<br>                [flutterX86JarTask, releaseFlutterJar]<br>            } else {<br>                releaseFlutterJar<br>            }<br>        })<br>    }<br>}</p>
<p>private Properties readPropertiesIfExist(File propertiesFile) {<br>    Properties result = new Properties()<br>    if (propertiesFile.exists()) {<br>        propertiesFile.withReader(‘UTF-8’) { reader -&gt; result.load(reader) }<br>    }<br>    return result<br>}</p>
<p>afterEvaluate {<br>    android.libraryVariants.all { def variant -&gt;<br>        // println variant.mergeAssets.outputDir<br>        // println variant.buildType.debuggable</p>
<pre><code>    def flutterAsset = files(&quot;../../build&quot;)
    def flutterAOT = files(&quot;../../build/aot&quot;)
    def mergeFlutterAssets = project.tasks.create(name: &quot;mergeFlutterAssets${variant.name.capitalize()}&quot;, type: Copy) {
        // dependsOn copySharedFlutterAssetsTask
        dependsOn variant.mergeAssets

        from (flutterAsset){
            include &quot;flutter_assets/**&quot;
            exclude{
                 details -&gt;details.file.name.contains(&#39;isolate_snapshot_data&#39;) ||
                         details.file.name.contains(&#39;vm_snapshot_data&#39;) ||
                         details.file.name.contains(&#39;kernel_blob.bin&#39;)
            }
        }

        from (flutterAOT){
            include &quot;vm_snapshot_data&quot;
            include &quot;vm_snapshot_instr&quot;
            include &quot;isolate_snapshot_data&quot;
            include &quot;isolate_snapshot_instr&quot;
        }

        into variant.mergeAssets.outputDir

    }
    variant.outputs[0].processResources.dependsOn(mergeFlutterAssets)
}</code></pre><p>}</p>
<p>dependencies {<br>    implementation fileTree(dir: ‘libs’, include: [‘*.jar’])<br>    implementation ‘com.android.support:appcompat-v7:28.0.0-alpha1’<br>    testImplementation ‘junit:junit:4.12’<br>    androidTestImplementation ‘com.android.support.test:runner:1.0.2’<br>    androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’<br>}</p>
<pre><code>


### 编写 Flutter 插件和 Flutter Module 项目自动化 shell 脚本构建

- 项目 AOT 和 Bundle 编译 ${root}/script/project.sh

```bash
#!/bin/bash
root=`pwd`

. &quot;${root}/script/util.sh&quot;

green &quot;--root: ${root}, build mode: ${build},  run mode: ${run}&quot;

green &quot;--start flutter aot and bundle build&quot;

flutter clean

if [[ $build = &quot;debug&quot; ]]
then
   # green &quot;&gt;&gt;flutter build aot --debug &amp;&amp; flutter build bundle --debug&quot;
   # android-arm does not support AOT compilation
   # flutter build aot --debug
   # flutter build bundle --debug
   green &quot;--android-arm does not support AOT compilation, use release build aot&quot;
   yellow &quot;&gt;&gt;flutter build aot --release &amp;&amp; flutter build bundle --debug&quot;
   # android-arm does not support AOT compilation
   flutter build aot --release
   flutter build bundle --debug
   if [[ $build = &#39;debug&#39; ]] &amp;&amp; [[ $run = &#39;simulator&#39; ]]; then
      cp -f &quot;${root}/build/flutter_assets/vm_snapshot_data&quot;       &quot;${root}/build/aot/vm_snapshot_data&quot;
      cp -f &quot;${root}/build/flutter_assets/isolate_snapshot_data&quot;  &quot;${root}/build/aot/isolate_snapshot_data&quot;
      green &quot;&gt;&gt;when debug and simulator mode, copy snapshot successfully!&quot;
   fi
   yellow &quot;&gt;&gt;./gradlew assembleDebug&quot;
   cd android &amp;&amp; ./gradlew clean &amp;&amp; ./gradlew assembleDebug
   cd ..
else
   yellow &quot;&gt;&gt;flutter build aot --release &amp;&amp; flutter build bundle --release&quot;
   flutter build aot --release
   flutter build bundle --release
   yellow &quot;&gt;&gt;./gradlew assembleRelease&quot;
   cd android &amp;&amp; ./gradlew clean &amp;&amp; ./gradlew assembleRelease
   cd ..
fi

green &quot;--flutter arr file[ ${root}/android/app/build/outputs/aar/app-${build}.aar ] build successfully!&quot;


cp -f &quot;${root}/android/app/build/outputs/aar/app-${build}.aar&quot;  &quot;${root}/publish/${build}&quot;
</code></pre><ul>
<li>Flutter 插件 .aar 文件生成和处理 ${root}/script/plugin.sh</li>
</ul>
<p>这里是直接从 Flutter 插件编译的缓存目录拷贝 .arr 文件。目前需要自己手动在 Flutter Module 项目目录下执行 <strong>flutter build apk –debug</strong> 和** flutter build apk –release** 命令生成插件的  debug 和 release .arr 文件.</p>
<pre class=" language-bash"><code class="language-bash"><span class="token shebang important">#!/bin/bash</span>

root<span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">pwd</span><span class="token variable">`</span></span>

<span class="token keyword">.</span> <span class="token string">"<span class="token variable">${root}</span>/script/util.sh"</span>

<span class="token keyword">echo</span> <span class="token string">"start flutter plugin aar copy......"</span>

<span class="token keyword">for</span> line <span class="token keyword">in</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> .flutter-plugins<span class="token variable">)</span></span>
<span class="token keyword">do</span>
    arr<span class="token operator">=</span><span class="token punctuation">(</span><span class="token variable">${line/=/ }</span><span class="token punctuation">)</span>
    name<span class="token operator">=</span><span class="token variable">${arr[0]}</span>
    path<span class="token operator">=</span><span class="token variable">${arr[1]}</span>
    plugin_name<span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">basename</span> $path<span class="token variable">`</span></span>
    plugin_dir<span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span><span class="token function">dirname</span> $path<span class="token variable">)</span></span>
    plugin<span class="token operator">=</span><span class="token variable">${path}</span>android

    aar<span class="token operator">=</span><span class="token string">"<span class="token variable">${path}</span>android/build/outputs/aar/<span class="token variable">${name}</span>-<span class="token variable">${build}</span>.aar"</span>
    <span class="token keyword">if</span> <span class="token punctuation">[</span> <span class="token operator">!</span> -f <span class="token variable">$arr</span> <span class="token punctuation">]</span>
    <span class="token keyword">then</span>
       <span class="token function">cp</span> -f <span class="token variable">$aar</span> <span class="token string">"<span class="token variable">${root}</span>/publish/<span class="token variable">${build}</span>"</span>
    <span class="token keyword">else</span>
       <span class="token keyword">echo</span> <span class="token string">"<span class="token variable">$aar</span> is not exists"</span>
    <span class="token keyword">fi</span>
<span class="token keyword">done</span>

<span class="token keyword">echo</span> <span class="token string">"flutter plugin copy successfully!"</span></code></pre>
<ul>
<li>拷贝 Flutter Module 生成的 .aar 文件给 Android Native 项目的  app/libs 目录  ${root}/script/copy.sh</li>
</ul>
<blockquote>
<p>HappyAndroid 为 Native 项目名称，  Android Native 项目 和 Flutter Module 项目放到同一根目录下即可</p>
</blockquote>
<pre class=" language-bash"><code class="language-bash"><span class="token shebang important">#!/bin/bash</span>

root<span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">pwd</span><span class="token variable">`</span></span>

<span class="token keyword">.</span> <span class="token string">"<span class="token variable">${root}</span>/script/util.sh"</span>

<span class="token function">rm</span> -rf <span class="token string">"../HappyAndroid/app/libs/"</span>
<span class="token function">cp</span> -r <span class="token string">"<span class="token variable">${root}</span>/publish/<span class="token variable">${build}</span>/"</span>  <span class="token string">"../HappyAndroid/app/libs"</span></code></pre>
<h3 id="运行-shell-命令生成-arr-文件-root-script-build-sh"><a href="#运行-shell-命令生成-arr-文件-root-script-build-sh" class="headerlink" title="运行 shell 命令生成 .arr 文件 ${root}/script/build.sh"></a>运行 shell 命令生成 .arr 文件 ${root}/script/build.sh</h3><pre class=" language-bash"><code class="language-bash"><span class="token shebang important">#!/bin/bash</span>
root<span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">pwd</span><span class="token variable">`</span></span>

<span class="token keyword">.</span> <span class="token string">"<span class="token variable">${root}</span>/script/project.sh"</span>
<span class="token keyword">.</span> <span class="token string">"<span class="token variable">${root}</span>/script/plugin.sh"</span>
<span class="token keyword">.</span> <span class="token string">"<span class="token variable">${root}</span>/script/copy.sh"</span></code></pre>
<ul>
<li>生成 debug .aar 模拟器包：  <strong>./script/build.sh  build=debug</strong></li>
<li>生成 debug .aar 真机包：     <strong>./script/build.sh  build=debug</strong></li>
<li>生成 release .aar 真机包：   <strong>./script/build.sh  build=release</strong></li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2019/png/116733/1561097691639-c1dbc1f8-8293-41f4-b2e6-6503eabaee46.png#align=left&display=inline&height=249&name=image.png&originHeight=249&originWidth=616&size=65388&status=done&width=616" alt="image.png"></p>
<p>最后，按照正常的 Android Native 工程运行方式运行项目，即可 Running！</p>
<h3 id=""><a href="#" class="headerlink" title=""></a></h3><h2 id="常见问题"><a href="#常见问题" class="headerlink" title="常见问题"></a>常见问题</h2><table>
<thead>
<tr>
<th>打包模式</th>
<th>运行模式</th>
<th>构建</th>
<th>依赖包</th>
<th>可运行</th>
</tr>
</thead>
<tbody><tr>
<td>Debug</td>
<td>模拟器</td>
<td><br />- flutter build aot –release<br />- flutter build bundle –debug<br /></td>
<td>android-arm-release/flutter.jar<br />或<br />android-x64/flutter.jar</td>
<td>✅<br />条件：复制 flutter_assets 里面的isolate_snapshot_data 和 vm_snapshot_data 覆盖 aot 里面的 isolate_snapshot_data 和 vm_snapshot_data</td>
</tr>
<tr>
<td></td>
<td>真机</td>
<td><br />- flutter build aot –release<br />- flutter build bundle –debug<br /></td>
<td>android-arm-release/flutter.jar</td>
<td>✅</td>
</tr>
<tr>
<td></td>
<td>真机</td>
<td><br />- flutter build aot –release<br />- flutter build bundle –release<br /></td>
<td>android-arm-release/flutter.jar</td>
<td>✅</td>
</tr>
<tr>
<td></td>
<td>真机</td>
<td><br />- flutter build aot –release<br />- flutter build bundle –debug<br /></td>
<td>android-arm/flutter.jar</td>
<td>❌<br />Error:JIT runtime cannot run a precompiled snapshot</td>
</tr>
<tr>
<td></td>
<td>真机</td>
<td><br />- flutter build aot –debug<br />- flutter build bundle –debug<br /></td>
<td>android-arm/flutter.jar<br />或<br />android-arm-release/flutter.jar</td>
<td>❌<br />android-arm does not support AOT compilation</td>
</tr>
<tr>
<td>Release</td>
<td>模拟器</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>真机</td>
<td><br />- flutter build aot –release<br />- flutter build bundle –release<br /></td>
<td>android-arm-release/flutter.jar</td>
<td>✅</td>
</tr>
</tbody></table>

                </div>
                <hr/>
    
                

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        Author:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://easy-team.github.io" rel="external nofollow noreferrer">sky</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        Link:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://easy-team.github.io/blog/lsrssy/">https://easy-team.github.io/blog/lsrssy/</a>
                </span>
            </div>
            <div class="reprint__type">
                    <span class="reprint-meta" style="font-weight: bold;">
                        <i class="fas fa-link">
                            yuque:
                        </i>
                    </span>
                    <span class="reprint-info">
                        <a href="https://yuque.com/easy-team/blog/lsrssy/" target="_blank" rel="noopener">https://yuque.com/easy-team/blog/lsrssy/</a>
                    </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        Reprint policy:
                    </i>
                </span>
                <span class="reprint-info">
                    All articles in this blog are used except for special statements
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    reprint polocy. If reproduced, please indicate source
                    <a href="https://easy-team.github.io" target="_blank">sky</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>Copied successfully, please follow the reprint policy of this article</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">more</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>


    
                <div class="tag_share" style="display: block; margin-top: 20px;">
                    <div class="post-meta__tag-list" style="display: inline-block;">
                        
                            
                        
                    </div>
                    <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                        <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                    </div>

                </div>
                
            </div>
        </div>
        
    
        
    
        
    
        
    
        
    
        

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;Previous</div>
            <div class="card">
                <a href="/blog/vfhw62/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/22.jpg" class="responsive-img" alt="Git 使用技巧">
                        
                        <span class="card-title">Git 使用技巧</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            原文： http://hubcarl.github.io/blog/2017/09/23/git/Git保存用户名密码git config credential.helper storeGit分支批量清理本地分支git branch | grep -E feature\/(1\.|activi...
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2019-10-20
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            sky
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                Next&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/blog/kghphs/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/16.jpg" class="responsive-img" alt="React Native代码执行跟踪和调试">
                        
                        <span class="card-title">React Native代码执行跟踪和调试</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            原文 http://hubcarl.github.io/blog/2016/09/04/react-native-debug/在本地开发时, React Native 是加载本地Node服务, 可以通过npm start 启动， package.json 代码如下：&quot;scripts&...
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2019-10-20
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            sky
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

     </div>
</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('50')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + 'From: easy-team<br />'
            + 'Author: sky<br />'
            + 'Link: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->

<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>


<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>

    
<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>

<!-- menu-selected -->
<script>
    var pathname = location.pathname.replace(/^\//, '').replace(/\/$/, '').replace(/\//g, '-');
    $('#m-nav-item-' + pathname).addClass('doc-left-nav-mene-selected');
</script>

    <footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">年份</span>
            <a href="https://easy-team.github.io" target="_blank">sky</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/easy-team" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">106.5k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    window.setTimeout("siteTime()", 1000);
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2019";
                    var startMonth = "10";
                    var startDate = "20";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/hubcarl" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:hubcarl@126.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=433207205" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 433207205" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>



    <a href="https://weibo.com/hubcarl" class="tooltipped" target="_blank" data-tooltip="关注我的微博: https://weibo.com/hubcarl" data-position="top" data-delay="50">
        <i class="fab fa-weibo"></i>
    </a>



    <a href="https://zhuanlan.zhihu.com/easywebpack" class="tooltipped" target="_blank" data-tooltip="关注我的知乎: https://zhuanlan.zhihu.com/easywebpack" data-position="top" data-delay="50">
        <i class="fab fa-zhihu1">知</i>
    </a>



    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;Search</span>
            <input type="search" id="searchInput" name="s" placeholder="Please enter a search keyword"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    

    <!-- Global site tag (gtag.js) - Google Analytics -->


    <!-- Baidu Analytics -->


    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        bp.async = true;
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
